import greenfoot.*;

/**
 * This class defines a crab. Crabs live on the beach.
 */
public class Crab extends Actor
{
    private GreenfootImage image1=null;
    private GreenfootImage image2=null;
    
 public Crab(){
    image1=new GreenfootImage("crab.png");
    image2=new GreenfootImage("crab2.png");
    setImage(image1);
    }
    public void act()
    {
      move(5) ;
      KeyControl();
      animation();
}
public void  KeyControl() {
if(Greenfoot.isKeyDown("left")) {
          turn(15);
        }
if(Greenfoot.isKeyDown("right")){
  turn(-15);
}
}
public void animation(){

if(getImage()==image1){
    setImage(image2);
}else{
   setImage(image1);
}

}
}
